<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/jquery-1.10.1.min.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .wrap {
            width: 400px;
            height: 400px;
            background-color: #6ff;
            overflow: hidden;
            margin: 100px;
            position: relative;
        }

        .sub {
            width: 300px;
            height: 300px;
            background-color: #f00;
            overflow: hidden;
            margin: 50px;
        }

        .txt {
            width: 100px;
            height: 100px;
            background-color: blue;
            overflow: hidden;
            margin: 100px;
        }
    </style>
</head>

<body>
    <div class="wrap">
        <div class="sub">
            <div class="txt"></div>
        </div>
    </div>
</body>
<script>
    // offset()  获取匹配的元素相对于文档(body)的偏移  =>{left,top}


    console.log($(".txt").offset());


</script>

</html>